﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Threading;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class ConversationForm : Form
    {
        protected string username;

        public ConversationForm(string username)
        {
            this.username = username;
            InitializeComponent();
            this.ActiveControl = textBox2;
            writeIncomingData(this.username);
        }
        
        public string getUsername()
        {
            return username;
        }

        //Delegate function so we can receive text from other threads.
        public delegate void UpdateTextCallback(string message);

        //Writes incoming text to the textbox.
        public void writeIncomingData(string text)
        {
            textBox1.AppendText(text + Environment.NewLine);

            //Stop the scrollbar from jumping up on new line
            textBox1.Select(textBox1.Text.Length - 1, 1);
            textBox1.ScrollToCaret();

        }
        /*
        //Detects the Enter keypress and sends the commands onwards for parsing.
        public void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (int)Keys.Enter)
            {
                //Send the input to the parser.
                client.sendParse(textBox2.Text, channel.getChannelName());
                //Reset the textbox to empty
                textBox2.Text = "";
            }
        }
        
        private void button1_Click(object sender, EventArgs e)
        {
            //client.sendParse(textBox2.Text);
            textBox2.Text = "";
        }*/
    }
}
